package korkd.tower;

import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.util.pool.GenericPool;

public class BulletPool extends GenericPool<Bullet> {

	private TextureRegion mTextureRegion;
	private Scene mScene;
	
	BulletPool(TextureRegion pTextureRegion, Scene pScene)
	{
		mTextureRegion = pTextureRegion;
		mScene = pScene;
	}
	@Override
	protected Bullet onAllocatePoolItem() {
		Bullet tBullet = new Bullet(0, 0, mTextureRegion.deepCopy());
		mScene.attachChild(tBullet);
		return tBullet;
	}
	
	@Override
	protected void onHandleRecycleItem(final Bullet pBullet)
	{
		pBullet.setIgnoreUpdate(true);
		pBullet.setVisible(false);
	}
	
	@Override
	protected void onHandleObtainItem(final Bullet pBullet)
	{
		pBullet.reset();
	}

}